import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';

/// @Author wywinstonwy
/// @Date 2022/1/22 5:00 下午
/// @Description: 

class MyConstrainers extends StatefulWidget {
  const MyConstrainers({Key? key}) : super(key: key);

  @override
  _MyConstrainersState createState() => _MyConstrainersState();
}

class _MyConstrainersState extends State<MyConstrainers> {
  Widget redBox = DecoratedBox(decoration: BoxDecoration(color: Colors.red));
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('组件约束'),
        actions: [
          UnconstrainedBox(child: SizedBox(
            width: 20,
            height: 20,
            child: CircularProgressIndicator(strokeWidth: 3,valueColor: AlwaysStoppedAnimation(Colors.white70),),
          ),)

        ],
      ),
      body: _buildUnconstainers1(),
    );
  }

  _buildConstrainedBox(){
    return ConstrainedBox(
        constraints: const BoxConstraints(
            minWidth: double.infinity,
            minHeight: 50//最小高度为50像素
        ),
      child: Container(height: 5.0,
        child: redBox,
    ),
    );
  }
  _buildUnconstainers(){
    return ConstrainedBox(
        constraints: const BoxConstraints(minWidth: 60.0, minHeight: 100.0),  //父
        child: UnconstrainedBox( //“去除”父级限制
          child: ConstrainedBox(
            constraints: BoxConstraints(minWidth: 90.0, minHeight: 20.0),//子
            child: redBox,
          ),
        )
    );
  }
  _buildUnconstainers1(){
    return Column(
      children: [
        UnconstrainedBox(
          alignment: Alignment.topLeft,
          child: Padding(padding: EdgeInsets.all(16),
            child: Row(children: [Text('xx'*30)],),
          ),
        )
      ],
    );
  }
}
